{extend name="admin/layout" /}
{block name="main"}
<div class="row">
    <div class="col-md-12">
        <div class="widget">
            <header class="widget-header">
                <h4 class="widget-title">{$webTitle}
                </h4>
            </header><!-- .widget-header -->
            <hr class="widget-separator">
            <div class="widget-body">
                <form method="post">
                    <input type="hidden" name="action" value="search">
                    <div class="input-group xs-mb-15">
                        <input type="text" placeholder="请输入要搜索的QQ！" name="s"
                               class="form-control text-center"
                               required>
                        <span class="input-group-btn">
                        <button type="submit" class="btn btn-primary">立即搜索</button>
                        </span>
                    </div>
                </form>
            </div>
            <hr class="widget-separator">
            <div class="alert alert-info text-center">
                批量改变状态：<a class="btn-xs btn-info" onclick="action(1);">进行中</a> <a class="btn-xs btn-success"
                                                                                  onclick="action(2);">已完成</a> <a
                    class="btn-xs btn-warning" onclick="action(3);">异常</a> <a class="btn-xs btn-danger"
                                                                              onclick="action(9);">删除</a>
            </div>
            <div class="widget-body table-responsive">
                <table class="table table-hover table-striped">
                    <thead>
                    <tr>
                        <th>
                            <input type="checkbox" id="checkboxAll"> ID
                        </th>
                        <th class="text-center">Q Q</th>
                        <th class="text-center">份数</th>
                        <th class="text-center">下单时间</th>
                        <th class="text-center">状态</th>
                    </tr>
                    </thead>
                    <tbody id="table">
                    {volist name="orderList" id="order" }
                    <tr>
                        <td><input type="checkbox" dataid="{$order.id}"> #{$order.id}</td>
                        <td class="text-center">{$order.uin}</td>
                        <td class="text-center">{$order.num}</td>
                        <td class="text-center">{$order.addtime}</td>
                        <td class="text-center">
                            {if condition="$order.status eq 0"}
                            等待中
                            {elseif condition="$order.status eq 1"}
                            进行中
                            {elseif condition="$order.status eq 2"}
                            已完成
                            {elseif condition="$order.status eq 3"}
                            异常
                            {/if}
                        </td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
                <div class="text-center">{$pageList->showPage()}</div>
            </div>
        </div>
    </div>
</div>
<form id="actionForm" method="post">
    <input type="hidden" name="ids">
    <input type="hidden" name="action">
</form>
{/block}
{block name="footJs"}
<script>
    $(document).ready(function () {
        $("#checkboxAll").click(function () {
            if (this.checked) {
                $("#table :checkbox").prop("checked", true);
            } else {
                $("#table :checkbox").prop("checked", false);
            }
        });
    });
    function action(i) {
        if (i == 9) {
            if (!confirm("确认删除？")) {
                return false;
            }
        }
        var ids = "";
        $("#table :checkbox").each(function () {
            if ($(this).prop("checked")) {
                ids += $(this).attr('dataid') + ',';
            }
        });
        if (ids == "") {
            alert("请先选择要操作的订单");
            return false;
        }
        $("#actionForm input[name='ids']").val(ids);
        $("#actionForm input[name='action']").val(i);
        $("#actionForm").submit();

    }
</script>
{/block}